<?php
namespace Admin\Controller;
use Think\Controller;

class AdmineditController extends CommonController {
    public function index(){
        $uid=I('get.uid');

        $admin=M('auth_group_access')->find($uid);

        $group=M('auth_group')->field('id,title')->select();

        $this->assign('admin',$admin);

        $this->assign('group',$group);

        $this->display();
    }

    public function edit(){
    	$data = I('post.');
    	//var_dump($data);exit;
    	$check = D('auth_group_access');
		if(!$check->create($data,3)){
			$this->ajaxreturn(['error'=>1,'info'=>$check->getError()]);
		}
		$resN=M('auth_group_access')->where(['username'=>$data['username'],'uid'=>['neq',$data['uid']]])->select();
		if($resN){
			$this->ajaxReturn(['error'=>1,'info'=>"昵称已存在"]);
		};
		$resP=M('auth_group_access')->where(['phone'=>$data['phone'],'uid'=>['neq',$data['uid']]])->select();
		if($resP){
			$this->ajaxReturn(['error'=>1,'info'=>"手机已被注册"]);
		};
		$resE=M('auth_group_access')->where(['email'=>$data['email'],'uid'=>['neq',$data['uid']]])->select();
		if($resE){
			$this->ajaxReturn(['error'=>1,'info'=>"邮箱已被注册"]);
		};
		$data['password'] = md5($data['pass']);
		M('auth_group_access')->where(['uid'=>$data['uid']])->save($data);
		$this->ajaxReturn(['error'=>0,'info'=>"修改成功"]);
    }
}

?>